package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityPageQueryDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 运营端 - 活动管理控制器
 * @author JIAN
 */
@Slf4j
@RestController("operationActivityController")
@RequestMapping("/operation/activity")
public class ActivityController {
    @Resource
    private IActivityService activityService;

    @GetMapping("/page")
    public PageResult<ActivityInfoResDTO> pageActivity(ActivityPageQueryDTO activityPageQueryDTO) {
        return activityService.page(activityPageQueryDTO);
    }

    @GetMapping("/{id}")
    public ActivityInfoResDTO getActivity(@PathVariable Long id) {
        return activityService.getDetailById(id);
    }

    @PostMapping("/save")
    public void saveOrUpdateActivity(@RequestBody ActivitySaveReqDTO activitySaveReqDTO) {
        activityService.saveOrUpdate(activitySaveReqDTO);
    }

    @PostMapping("/revoke/{id}")
    public void revokeActivity(@PathVariable Long id) {
        activityService.revoke(id);
    }
}